# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=golang-golang-x-mod
pkgver=0.0.20220818
_commit=ed83ed61efb973124a2a93983ae1ff1431207a45
pkgrel=1
pkgdesc='Packages for writing tools that work directly with Go module mechanics'
arch=('any')
url="https://github.com/golang/mod"
license=('BSD')
depends=('go' 'golang-golang-x-crypto' 'golang-golang-x-tools')
checkdepends=('git')
source=("$pkgname-$_commit.tar.gz::https://github.com/golang/mod/archive/$_commit.tar.gz")
sha512sums=('3b0507a05d2377ce4a468109219c884e35aed43cd685ff18f746425896290fe120f010606ec53058ad0da1c7ed0631bd6e1679e576c29ab3fbf13543627a0c2f')

check() {
  export GO111MODULE=off
  export GOPATH="$srcdir/build:/usr/share/gocode"
  mkdir -p "$srcdir"/build/src/golang.org/x
  cp -a "$srcdir"/mod-$_commit "$srcdir"/build/src/golang.org/x/mod
  cd "$srcdir"/build/src/golang.org/x/mod
  go test -v $(go list ./...)
}

package() {
  mkdir -p "$pkgdir"/usr/share/gocode/src/golang.org/x
  cp -a "$srcdir"/mod-$_commit "$pkgdir"/usr/share/gocode/src/golang.org/x/mod

  install -Dm644 mod-$_commit/LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
